<?php

namespace extend\oss;


use AlibabaCloud\Client\AlibabaCloud;

class OssVideo extends Base
{
    function initVodClient()
    {
        $config = $this->config;

        $regionId = 'cn-shanghai';
        AlibabaCloud::accessKeyClient($config['accessKeyId'], $config['accessKeySecret'])
            ->regionId($regionId)
            ->connectTimeout(1)
            ->timeout(3)
            ->name(VOD_CLIENT_NAME);
    }


    /**
     * 获取视频上传地址和凭证
     * @param client 发送请求客户端
     * @return CreateUploadVideoResponse 获取视频上传地址和凭证响应数据
     */
    function createUploadVideo($client) {
        $request = new vod\CreateUploadVideoRequest();
        $request->setTitle("Sample Title");
        $request->setFileName("videoFile.mov");
        $request->setDescription("Video Description");
        $request->setCoverURL("http://192.168.0.0/16/tps/TB1qnJ1PVXXXXXCXXXXXXXXXXXX-700-700.png");
        $request->setTags("tag1,tag2");

        $request->setAcceptFormat('JSON');
        return $client->getAcsResponse($request);
    }

//try {
//$client = initVodClient('<AccessKeyId>', '<AccessKeySecret>');
//
//$uploadInfo = createUploadVideo($client);
//var_dump($uploadInfo);
//} catch (Exception $e) {
//    print $e->getMessage()."\n";
//}



}